package com.netintech.intelligenceInterface.iflytek.controller;

import com.netintech.intelligenceInterface.iflytek.domain.chineseWordCut.ChineseWordCutMultiParam;
import com.netintech.intelligenceInterface.iflytek.domain.chineseWordCut.ChineseWordCutSingleParam;
import com.netintech.intelligenceInterface.iflytek.util.RestTemplateUtil;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import static com.netintech.intelligenceInterface.common.StaticBean.URL1;
import static com.netintech.intelligenceInterface.iflytek.domain.IFlyTekKey.API_KEY;
import static com.netintech.intelligenceInterface.iflytek.domain.IFlyTekKey.API_SECRET;

import java.util.Collections;
import java.util.Map;

/**
 * @author lining
 * @date 2021/4/28 9:30
 * 中文分词接口
 */
@RestController
public class ChineseWordCutController {

    /**
     * 单文本中文分词接口路径
     */
    private static final String SINGLE_TEXT_WORD_CUT_URL = "/tuling/ws/v2/process";
    /**
     * 多文本中文分词接口路径
     */
    private static final String MULTI_TEXT_WORD_CUT_URL = "/tuling/ws/v2/multiprocess";
    /**
     * 中文分词结构化输出
     */
    private static final String SINGLE_TEXT_WORD_CUT_STRUCTURED = "/tuling/ws/v2/single";

    @PostMapping("/singleTextWordCut")
    public String chineseWordCut(@RequestBody ChineseWordCutSingleParam param) {
        String url = URL1 + SINGLE_TEXT_WORD_CUT_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/singleTextWordCut")
    public String chineseWordCutTest(@RequestBody ChineseWordCutSingleParam param) {
        String url = URL1 + SINGLE_TEXT_WORD_CUT_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/multiTextWordCut")
    public String multiTextWordCut(@RequestBody ChineseWordCutMultiParam param) {
        String url = URL1 + MULTI_TEXT_WORD_CUT_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/multiTextWordCut")
    public String multiTextWordCutTest(@RequestBody ChineseWordCutMultiParam param) {
        String url = URL1 + MULTI_TEXT_WORD_CUT_URL;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }


    @PostMapping("/singleTextWordCutStructured")
    public String singleTextWordCutStructured(@RequestBody ChineseWordCutSingleParam param){
        String url = URL1 + SINGLE_TEXT_WORD_CUT_STRUCTURED;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }

    @PostMapping("/test/singleTextWordCutStructured")
    public String singleTextWordCutStructuredTest(@RequestBody ChineseWordCutSingleParam param){
        String url = URL1 + SINGLE_TEXT_WORD_CUT_STRUCTURED;
        return RestTemplateUtil.getRestTemplateResult(url, param);
    }


}
